package com.data.modules.gd.service.impl;

import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.data.common.constant.MsgConstants;
import com.data.common.constant.enums.ProductEnum;
import com.data.common.util.KamliClientUtil;
import com.data.modules.gd.entity.SmUpgradeVersion;
import com.data.modules.gd.mapper.SmUpgradeVersionMapper;
import com.data.modules.gd.service.ISmUpgradeVersionService;
import com.data.modules.smzh.entity.Facedevice;
import com.data.modules.system.vo.SysUserRoleVO;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Description: 新闻屏升级版本表
 * @Author: data-boot
 * @Date:   2023-08-22
 * @Version: V1.0
 */
@Service
public class SmUpgradeVersionServiceImpl extends ServiceImpl<SmUpgradeVersionMapper, SmUpgradeVersion> implements ISmUpgradeVersionService {

    @Override
    public void sendUpgradeMsg(SysUserRoleVO sysUserRoleVO) {

        String id = sysUserRoleVO.getRoleId();
        SmUpgradeVersion version = this.getById(id);

        String cmd = MsgConstants.UPGRADE_VERSION_MSG;
        List<Map> list = new ArrayList<>();
        Map<String,Object> map = new HashMap<>();
        map.put("model", ProductEnum.SMW_GDXW.getCode());
        map.put("url",version.getUrl());
        list.add(map);

        for(String sysUserId:sysUserRoleVO.getUserIdList()) {

            KamliClientUtil.doPostpushMsgUr(sysUserId, cmd,list);

        }

    }


}
